package com.ruoyi.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.BaseStorageDeviceMapper;
import com.ruoyi.domain.BaseStorageDevice;
import com.ruoyi.service.IBaseStorageDeviceService;

/**
 * 存储设备Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-13
 */
@Service
public class BaseStorageDeviceServiceImpl implements IBaseStorageDeviceService 
{
    @Autowired
    private BaseStorageDeviceMapper baseStorageDeviceMapper;

    /**
     * 查询存储设备
     * 
     * @param id 存储设备主键
     * @return 存储设备
     */
    @Override
    public BaseStorageDevice selectBaseStorageDeviceById(Long id)
    {
        return baseStorageDeviceMapper.selectBaseStorageDeviceById(id);
    }

    /**
     * 查询存储设备列表
     * 
     * @param baseStorageDevice 存储设备
     * @return 存储设备
     */
    @Override
    public List<BaseStorageDevice> selectBaseStorageDeviceList(BaseStorageDevice baseStorageDevice)
    {
        return baseStorageDeviceMapper.selectBaseStorageDeviceList(baseStorageDevice);
    }

    /**
     * 新增存储设备
     * 
     * @param baseStorageDevice 存储设备
     * @return 结果
     */
    @Override
    public int insertBaseStorageDevice(BaseStorageDevice baseStorageDevice)
    {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        baseStorageDevice.setUserId(user.getUserId());
        baseStorageDevice.setCreateTime(DateUtils.getNowDate());
        return baseStorageDeviceMapper.insertBaseStorageDevice(baseStorageDevice);
    }

    /**
     * 修改存储设备
     * 
     * @param baseStorageDevice 存储设备
     * @return 结果
     */
    @Override
    public int updateBaseStorageDevice(BaseStorageDevice baseStorageDevice)
    {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        baseStorageDevice.setUserId(user.getUserId());
        baseStorageDevice.setUpdateTime(DateUtils.getNowDate());
        return baseStorageDeviceMapper.updateBaseStorageDevice(baseStorageDevice);
    }

    /**
     * 批量删除存储设备
     * 
     * @param ids 需要删除的存储设备主键
     * @return 结果
     */
    @Override
    public int deleteBaseStorageDeviceByIds(Long[] ids)
    {
        return baseStorageDeviceMapper.deleteBaseStorageDeviceByIds(ids);
    }

    /**
     * 删除存储设备信息
     * 
     * @param id 存储设备主键
     * @return 结果
     */
    @Override
    public int deleteBaseStorageDeviceById(Long id)
    {
        return baseStorageDeviceMapper.deleteBaseStorageDeviceById(id);
    }
}
